import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import postcsspxtoviewport from 'postcss-px-to-viewport'
import legacy from "@vitejs/plugin-legacy"

export default defineConfig({
  base: './',
  plugins: [
    vue(),
    legacy({
      targets: ["ie>=11"],
      additionalLegacyPolyfills: ["regenerator-runtime/runtime"], //解决跨域警告
    })
  ],
  build: {
    sourcemap: false, // 禁用 sourcemap
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
        url: {
          strict: false, // 禁用严格 URL 处理
          inline: false  // 禁用内联数据 URI
        }
      },
    },
    postcss: {
      plugins: [
        postcsspxtoviewport({
          unitToConvert: 'px',
          viewportWidth: 1920,
          unitPrecision: 6,
          propList: ['*'],
          viewportUnit: 'vw',
          fontViewportUnit: 'vw',
          selectorBlackList: [],
          minPixelValue: 1,
          mediaQuery: false,
          replace: true,
          exclude: [],
          include: undefined,
          landscape: false,
          landscapeUnit: 'vw',
          landscapeWidth: 1920
        })
      ]
    }
  },
  resolve: {
    alias: {
      '@': '/src'
    }
  },
  server: {
    port: 8082,
    // host: '192.168.31.120',
    open: true,
    https: false
  }
})  